package de.mhu.mandalaui;

import java.util.HashMap;

import de.mhu.mandalaui.impl.DefaultUiFactory;

public abstract class Ui extends Component {

	private static UiFactory factory;
	private HashMap<String, Window> windows = new HashMap<String, Window>();
	private StyleUtil styleUtil = new StyleUtil();

	public static Window createWindow(String id) {
		Window window = getFactory().createWindow(id);
		window.componentAttach(getFactory().getUi());
		return window;
	}
	
	public static synchronized UiFactory getFactory() {
		if (factory == null)
			factory = new DefaultUiFactory(); // TODO strategy to find it...
		return factory;
	}

	public boolean isDebugRemoteCalls() {
		return true;
	}

	public void add(Window window) {
		windows.put(window.getId(), window);
		window.componentAttach(this);
	}
	
	public void remove(Window window) {
		window.componentDetach();
		windows.remove(window.getId());
	}

	public void close() {
		// TODO Auto-generated method stub
		
	}

	public Window getWindow(String id) {
		return windows.get(id);
	}

	public boolean isDebugFunctions() {
		return true;
	}

	public boolean isDebugDeadly() {
		return false;
	}

	public StyleUtil getStyleUtil() {
		return styleUtil ;
	}

}
